//加载用户畜栏数据----------------------------------------------------------------------
var current_player_farm;
function gamePlayerFarmInfo() {
	$.ajax({
		type:"post",
		url: ajaxUrl + "/game/1.0/sfg/player/farm.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG'
		},
		dataType:"json",
		success:function(request){
			console.log(request);
			if (request.code == 0) {
				current_player_farm = request.data;
				doSystemMessage('您终于回来啦，赶快看看有哪些变化吧......');
				gamePlayerFarmLandsDetail();/////////////////////////////////////////////////////////////////
			} else if (request.code == 2) {
				doSystemMessage(request.msg);
				current_player_farm = request.data;
				gamePlayerFarmLandsDetail();/////////////////////////////////////////////////////////////////
			} else {
				doErrorMessage(request.code, request.msg);
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}
//加载用户庄园土地数据----------------------------------------------------------------------
var current_player_farm_lands_detail;
function gamePlayerFarmLandsDetail() {
	$.ajax({
		type:"post",
		url: ajaxUrl + "/game/1.0/sfg/player/land.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG'
		},
		dataType:"json",
		success:function(request){
			console.log(request);
			if (request.code != 0) {
				doErrorMessage(request.code, request.msg);
			} else {		
				//数据整理为散列表
				current_player_farm_lands_detail = new HashTable(); 
				for(let i = 0 ; i < request.data.length ; i++){
					//console.log(request.data[i]);
					current_player_farm_lands_detail.put('land_'+request.data[i].landSort, request.data[i]);
				}
				////////////////////////界面初始化//////////////////////////
				//构建地图操作坐标-土地信息
				showPlayerFarmLandsDetail();
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}

////////////////////////////////////////////////////////////////////////////////
//构建土地
function showPlayerFarmLandsDetail(){
	//初始化
	let dom = $('#mapBackgroundDiv');
	dom.html('');
	let str = '';
	//区域蒙版
	//console.log(current_player_farm_lands_detail);
	for(let x = 0 ; x < 30 ; x ++){
		//console.log('land_==='+(x+1));
		var land = current_player_farm_lands_detail.get('land_'+(x+1));
		//console.log('land==='+land);
		if(checkEmpty(land)){//判断是否有效
			str =  str + '<div onclick="playerOperate(1,\'' + (x+1) + '\')" class="mapbox" id="mapbox_' + (x+1) + '">开垦</div>';
			break;
		}
		//landState(1未开垦2未种植3未翻地)
		str =  str + '<div onclick="playerOperate('+land.landState+',\'' + (x+1) + '\')" class="mapbox" id="mapbox_' + (x+1) + '">' + x + '</div>';
	}
	//console.log(str);
	dom.append(str);
}